package com.chinatsp.onlineapp.presenter;

import org.xutils.http.RequestParams;

import com.chinatsp.onlineapp.base.Config;
import com.chinatsp.onlineapp.bean.HostParamsBean;
import com.chinatsp.onlineapp.bean.LimitNum;
import com.google.gson.Gson;

import android.content.Context;
import tsp.cn.http.BaseIDao;
import tsp.cn.http.HttpConfig;
import tsp.cn.http.interfac.INetResult;
import tsp.cn.http.tools.LogUtil;
import tsp.cn.http.tools.PreferenceUtils;

public class HostDao extends BaseIDao{
	HostParamsBean mHostParamsResp;
	
	public HostDao(Context context, INetResult iNetResult) {
		super(context, iNetResult);
	}

	@Override
	public void onRequestSuccess(String result, int requestCode) {
		LogUtil.d( "HostDao  onRequestSuccess");
		mHostParamsResp = new Gson().fromJson(result, HostParamsBean.class);
	}
    public HostParamsBean getHostParamsBean(){
    	return mHostParamsResp;
    }
    
	/**
	 * 热门城市
	 */
	public void getHostParams() {
		String sn = PreferenceUtils.getSN();
		String url = "http://dns.yttsp.com/cfg/1.0/sn/"+sn+"/dns/";
		
		String customer_key = PreferenceUtils.getCustomeKey();
		String access_token = PreferenceUtils.getAccessTokenPublic();

		RequestParams params = new RequestParams(url);
		params.setHeader("Cookie", "customer_key="+customer_key+";access_token="+access_token+";");
		
		getRequest(params, Config.CODE_GET_HOST_PARAMS);
	}

}
